package light.head.model.inv;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;
/**
 * 入库信息
 * @author yy
 *
 */
@Entity
@Table
public class InvInStorage implements Serializable {
	
	private static final long serialVersionUID = 5102280742322697234L;
	
	private Integer code;
	private String dn;				// 入库单据编号（唯一性，按一定的规则生成RK20140604）
	private Byte type;				// 入库类型（1.调拨，2.退货，3.订单 4.其他）
	private Integer mc;				// 模块编号(根据入库类型确定是哪个业务的编号) 
	
	private Integer bc; 			// 供应商编号
	private Integer cu;				// 创建人
	private Integer oc;				// 机构编号
	private Date ct;				// 创建时间
	private Boolean deleted = false;// 是否删除
	private String remark;			// 备注

	private String bname;			// 供应商名称
	private String cn;
	private String on;
	private List<InvInStorageItem> itemList;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column(length = 50)
	public String getDn() {
		return dn;
	}
	@Column
	public Integer getBc() {
		return bc;
	}
	@Column
	public Integer getCu() {
		return cu;
	}
	@Column
	public Integer getOc() {
		return oc;
	}
	@Column
	public Integer getMc() {
		return mc;
	}
	@Column(nullable = false, updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCt() {
		return ct;
	}
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	@Column(length = 200)
	public String getRemark() {
		return remark;
	}
	@Transient
	public List<InvInStorageItem> getItemList() {
		return itemList;
	}
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = cu)")
	public String getCn() {
		return cn;
	}
	@Formula("(SELECT o.name FROM Organ o WHERE o.code = oc)")
	public String getOn() {
		return on;
	}
	@Formula("(SELECT ib.name FROM InvBusiness ib WHERE ib.code = bc)")
	public String getBname() {
		return bname;
	}
	@Column
	public Byte getType() {
		return type;
	}
	
	
	
	
	
	
	
	public void setType(Byte type) {
		this.type = type;
	}
	public void setBc(Integer bc) {
		this.bc = bc;
	}
	public void setBname(String bname) {
		this.bname = bname;
	}
	public void setOn(String on) {
		this.on = on;
	}
	public void setCn(String cn) {
		this.cn = cn;
	}
	public void setMc(Integer mc) {
		this.mc = mc;
	}
	public void setItemList(List<InvInStorageItem> itemList) {
		this.itemList = itemList;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setDn(String dn) {
		this.dn = dn;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setOc(Integer oc) {
		this.oc = oc;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	
	
	
}
